/*
 * ExcelBriniView.java
 */

package excelbrini;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 * The application's main frame.
 */
public class ExcelBriniView extends FrameView {
    private ExcelBriniApp app=null;
    public ExcelBriniView(SingleFrameApplication app) {
        super(app);
        this.app=(ExcelBriniApp)app;
       
        
        
        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ExcelBriniApp.getApplication().getMainFrame();
            aboutBox = new ExcelBriniAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        ExcelBriniApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        jButtonApriFile1 = new javax.swing.JButton();
        jButtonApriFile2 = new javax.swing.JButton();
        jTextFieldApriFile1 = new javax.swing.JTextField();
        jTextFieldApriFile2 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldOutputFile = new javax.swing.JTextField();
        jButtonOutputFile = new javax.swing.JButton();
        jButtonConfronta = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        jMenuItemImpostazioni = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jFileChooser1 = new javax.swing.JFileChooser();
        jFrameImpostazioni = new javax.swing.JFrame();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jTextFieldIntFile1 = new javax.swing.JTextField();
        jTextFieldIntFile2 = new javax.swing.JTextField();
        jButtonSalvaImpostazioni = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldCodOrdFile1 = new javax.swing.JTextField();
        jTextFieldRagSocFile1 = new javax.swing.JTextField();
        jTextFieldValVASfile1 = new javax.swing.JTextField();
        jTextFieldValADSLfile1 = new javax.swing.JTextField();
        jTextFieldCodOrdFile2 = new javax.swing.JTextField();
        jTextFieldRagSocFile2 = new javax.swing.JTextField();
        jTextFieldImportoFile2 = new javax.swing.JTextField();

        mainPanel.setName("mainPanel"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(excelbrini.ExcelBriniApp.class).getContext().getActionMap(ExcelBriniView.class, this);
        jButtonApriFile1.setAction(actionMap.get("segliFile1")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(excelbrini.ExcelBriniApp.class).getContext().getResourceMap(ExcelBriniView.class);
        jButtonApriFile1.setText(resourceMap.getString("jButtonApriFile1.text")); // NOI18N
        jButtonApriFile1.setName("jButtonApriFile1"); // NOI18N

        jButtonApriFile2.setAction(actionMap.get("segliFile2")); // NOI18N
        jButtonApriFile2.setText(resourceMap.getString("jButtonApriFile2.text")); // NOI18N
        jButtonApriFile2.setName("jButtonApriFile2"); // NOI18N

        jTextFieldApriFile1.setEditable(false);
        jTextFieldApriFile1.setText(resourceMap.getString("jTextFieldApriFile1.text")); // NOI18N
        jTextFieldApriFile1.setName("jTextFieldApriFile1"); // NOI18N

        jTextFieldApriFile2.setEditable(false);
        jTextFieldApriFile2.setText(resourceMap.getString("jTextFieldApriFile2.text")); // NOI18N
        jTextFieldApriFile2.setName("jTextFieldApriFile2"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jTextFieldOutputFile.setEditable(false);
        jTextFieldOutputFile.setText(resourceMap.getString("jTextFieldOutputFile.text")); // NOI18N
        jTextFieldOutputFile.setName("jTextFieldOutputFile"); // NOI18N

        jButtonOutputFile.setAction(actionMap.get("segliFileOutput")); // NOI18N
        jButtonOutputFile.setText(resourceMap.getString("jButtonOutputFile.text")); // NOI18N
        jButtonOutputFile.setActionCommand(resourceMap.getString("jButtonOutputFile.actionCommand")); // NOI18N
        jButtonOutputFile.setName("jButtonOutputFile"); // NOI18N

        jButtonConfronta.setAction(actionMap.get("confrontaFile")); // NOI18N
        jButtonConfronta.setText(resourceMap.getString("jButtonConfronta.text")); // NOI18N
        jButtonConfronta.setName("jButtonConfronta"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonConfronta, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 409, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                        .addComponent(jTextFieldApriFile2, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonApriFile2, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                        .addComponent(jTextFieldApriFile1, javax.swing.GroupLayout.PREFERRED_SIZE, 315, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonApriFile1, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE))
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(jTextFieldOutputFile, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonOutputFile, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonApriFile1)
                    .addComponent(jTextFieldApriFile1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonApriFile2)
                    .addComponent(jTextFieldApriFile2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTextFieldOutputFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonOutputFile))
                .addGap(13, 13, 13)
                .addComponent(jButtonConfronta)
                .addContainerGap())
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N
        fileMenu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                fileMenuMouseClicked(evt);
            }
        });

        jMenuItemImpostazioni.setAction(actionMap.get("showOption")); // NOI18N
        jMenuItemImpostazioni.setText(resourceMap.getString("jMenuItemImpostazioni.text")); // NOI18N
        jMenuItemImpostazioni.setName("jMenuItemImpostazioni"); // NOI18N
        fileMenu.add(jMenuItemImpostazioni);

        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 429, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 259, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        jFileChooser1.setName("jFileChooser1"); // NOI18N

        jFrameImpostazioni.setTitle(resourceMap.getString("jFrameImpostazioni.title")); // NOI18N
        jFrameImpostazioni.setMinimumSize(new java.awt.Dimension(420, 320));
        jFrameImpostazioni.setName("jFrameImpostazioni"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jSeparator2.setName("jSeparator2"); // NOI18N

        jTextFieldIntFile1.setText(resourceMap.getString("jTextFieldIntFile1.text")); // NOI18N
        jTextFieldIntFile1.setMinimumSize(new java.awt.Dimension(59, 20));
        jTextFieldIntFile1.setName("jTextFieldIntFile1"); // NOI18N

        jTextFieldIntFile2.setText(resourceMap.getString("jTextFieldIntFile2.text")); // NOI18N
        jTextFieldIntFile2.setMinimumSize(new java.awt.Dimension(59, 20));
        jTextFieldIntFile2.setName("jTextFieldIntFile2"); // NOI18N

        jButtonSalvaImpostazioni.setAction(actionMap.get("SaveOption")); // NOI18N
        jButtonSalvaImpostazioni.setText(resourceMap.getString("jButtonSalvaImpostazioni.text")); // NOI18N
        jButtonSalvaImpostazioni.setName("jButtonSalvaImpostazioni"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jTextFieldCodOrdFile1.setText(resourceMap.getString("jTextFieldCodOrdFile1.text")); // NOI18N
        jTextFieldCodOrdFile1.setName("jTextFieldCodOrdFile1"); // NOI18N

        jTextFieldRagSocFile1.setText(resourceMap.getString("jTextFieldRagSocFile1.text")); // NOI18N
        jTextFieldRagSocFile1.setName("jTextFieldRagSocFile1"); // NOI18N

        jTextFieldValVASfile1.setText(resourceMap.getString("jTextFieldValVASfile1.text")); // NOI18N
        jTextFieldValVASfile1.setName("jTextFieldValVASfile1"); // NOI18N

        jTextFieldValADSLfile1.setText(resourceMap.getString("jTextFieldValADSLfile1.text")); // NOI18N
        jTextFieldValADSLfile1.setName("jTextFieldValADSLfile1"); // NOI18N

        jTextFieldCodOrdFile2.setText(resourceMap.getString("jTextFieldCodOrdFile2.text")); // NOI18N
        jTextFieldCodOrdFile2.setName("jTextFieldCodOrdFile2"); // NOI18N

        jTextFieldRagSocFile2.setText(resourceMap.getString("jTextFieldRagSocFile2.text")); // NOI18N
        jTextFieldRagSocFile2.setName("jTextFieldRagSocFile2"); // NOI18N

        jTextFieldImportoFile2.setText(resourceMap.getString("jTextFieldImportoFile2.text")); // NOI18N
        jTextFieldImportoFile2.setName("jTextFieldImportoFile2"); // NOI18N

        javax.swing.GroupLayout jFrameImpostazioniLayout = new javax.swing.GroupLayout(jFrameImpostazioni.getContentPane());
        jFrameImpostazioni.getContentPane().setLayout(jFrameImpostazioniLayout);
        jFrameImpostazioniLayout.setHorizontalGroup(
            jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrameImpostazioniLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                    .addGroup(jFrameImpostazioniLayout.createSequentialGroup()
                        .addComponent(jButtonSalvaImpostazioni, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jFrameImpostazioniLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(10, 10, 10)
                        .addComponent(jTextFieldIntFile1, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jFrameImpostazioniLayout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(10, 10, 10)
                        .addComponent(jTextFieldIntFile2, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jFrameImpostazioniLayout.createSequentialGroup()
                        .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel11)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldCodOrdFile2, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
                            .addComponent(jTextFieldRagSocFile2, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
                            .addComponent(jTextFieldImportoFile2, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(jFrameImpostazioniLayout.createSequentialGroup()
                        .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6))
                        .addGap(18, 18, 18)
                        .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldRagSocFile1, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                            .addComponent(jTextFieldValVASfile1, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                            .addComponent(jTextFieldValADSLfile1, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                            .addComponent(jTextFieldCodOrdFile1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())))
        );
        jFrameImpostazioniLayout.setVerticalGroup(
            jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrameImpostazioniLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldCodOrdFile1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldRagSocFile1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldValVASfile1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextFieldValADSLfile1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldIntFile1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 3, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextFieldCodOrdFile2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTextFieldRagSocFile2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jTextFieldImportoFile2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jFrameImpostazioniLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextFieldIntFile2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButtonSalvaImpostazioni)
                .addContainerGap())
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void fileMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fileMenuMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_fileMenuMouseClicked

    @Action
    public void segliFile1() {
        String file_name =apriFile();
         jTextFieldApriFile1.setText(file_name);
         app.setFile_name1(file_name);
         jButtonConfronta.setEnabled(app.readyToGo());
    }
    @Action
    public void segliFile2() {
        String file_name =apriFile();
         jTextFieldApriFile2.setText(file_name);
         app.setFile_name2(file_name);
         jButtonConfronta.setEnabled(app.readyToGo());
    }
    @Action
    public void segliFileOutput() {
        FileFilter ft = new FileNameExtensionFilter("Excel Files", "xls");
        java.io.File file=null;
        jFileChooser1.addChoosableFileFilter(ft);
        int returnVal = jFileChooser1.showSaveDialog(jFileChooser1);
        if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
        file = jFileChooser1.getSelectedFile( );
        app.setFileOutput(file.toString());
        jTextFieldOutputFile.setText(file.toString());
        }
        jButtonConfronta.setEnabled(app.readyToGo());
    }
    
     public String apriFile() {
        FileFilter ft = new FileNameExtensionFilter("Excel Files", "xls");
        java.io.File file=null;
        jFileChooser1.addChoosableFileFilter(ft);
        int returnVal = jFileChooser1.showOpenDialog(jFileChooser1);
        if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
        file = jFileChooser1.getSelectedFile( );
        return file.toString( );
            }
        else        return "";
         
     }

    @Action
    public void showOption() {
        
        app.loadImpFromFile();
        jFrameImpostazioni.setVisible(true);
         jTextFieldIntFile1.setEnabled(true);
         jTextFieldIntFile2.setEnabled(true);
         jTextFieldCodOrdFile1.setEnabled(true);
        jTextFieldRagSocFile1.setEnabled(true);
        jTextFieldValVASfile1.setEnabled(true);
        jTextFieldValADSLfile1.setEnabled(true);
        jTextFieldCodOrdFile2.setEnabled(true);
        jTextFieldRagSocFile2.setEnabled(true);
        jTextFieldImportoFile2.setEnabled(true);
        //import valori correnti
        jTextFieldCodOrdFile1.setText(app.getLabelCodOrdFile1());
        jTextFieldRagSocFile1.setText(app.getLabelRagSocFile1());
        jTextFieldValVASfile1.setText(app.getLabelValVASfile1());
        jTextFieldValADSLfile1.setText(app.getLabelValADSLfile1());
        jTextFieldCodOrdFile2.setText(app.getLabelCodOrdFile2());
        jTextFieldRagSocFile2.setText(app.getLabelRagSocFile2());
        jTextFieldImportoFile2.setText(app.getLabelImportoFile2());
        int val1=app.getLabelIndexFile1()+1;
        jTextFieldIntFile1.setText("  "+val1);
        int val2=app.getLabelIndexFile2()+1;
        jTextFieldIntFile2.setText("  "+val2);
    }

    @Action
    public void SaveOption() {
        int val1=app.getLabelIndexFile1();
        int val2=app.getLabelIndexFile2();
       
        try{
        val1=Integer.parseInt(jTextFieldIntFile1.getText().trim());
        app.setLabelIndexFile1(val1-1);
        jTextFieldIntFile1.setEnabled(false);
        }catch(Exception e)
        {
            JOptionPane.showMessageDialog(jFrameImpostazioni,"valore errato in indice prima riga file1","Attenzione!",JOptionPane.ERROR_MESSAGE);
        }
        
        try{
        val2=Integer.parseInt(jTextFieldIntFile2.getText().trim());
        this.app.setLabelIndexFile2(val2-1);
        jTextFieldIntFile2.setEnabled(false);
        String labelCodOrdFile1=jTextFieldCodOrdFile1.getText();
        String labelRagSocFile1=jTextFieldRagSocFile1.getText();
        String labelValVASfile1=jTextFieldValVASfile1.getText();
        String labelValADSLfile1=jTextFieldValADSLfile1.getText();
        String labelCodOrdFile2=jTextFieldCodOrdFile2.getText();
        String labelRagSocFile2=jTextFieldRagSocFile2.getText();
        String labelImportoFile2=jTextFieldImportoFile2.getText();
        jTextFieldCodOrdFile1.setEnabled(false);
        jTextFieldRagSocFile1.setEnabled(false);
        jTextFieldValVASfile1.setEnabled(false);
        jTextFieldValADSLfile1.setEnabled(false);
        jTextFieldCodOrdFile2.setEnabled(false);
        jTextFieldRagSocFile2.setEnabled(false);
        jTextFieldImportoFile2.setEnabled(false);
        app.saveImpToFile();
        }catch(Exception e)
        {
           JOptionPane.showMessageDialog(jFrameImpostazioni,"valore errato in indice prima riga file2","Attenzione!",JOptionPane.ERROR_MESSAGE);
           
        }
        
        
    }

    @Action
    public void confrontaFile() {
        jButtonConfronta.setEnabled(false);
        int ret=this.app.confrontaFile();
        if(ret>0)JOptionPane.showMessageDialog(null,"confronto completato","Avviso",JOptionPane.INFORMATION_MESSAGE);
        else ShowError("confronto fallito err"+ret);
        jButtonConfronta.setEnabled(true);
    }

    public void ShowError(String str)
    {
     JOptionPane.showMessageDialog(jFrameImpostazioni,str,"Attenzione!",JOptionPane.ERROR_MESSAGE);
          
    }

    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonApriFile1;
    private javax.swing.JButton jButtonApriFile2;
    private javax.swing.JButton jButtonConfronta;
    private javax.swing.JButton jButtonOutputFile;
    private javax.swing.JButton jButtonSalvaImpostazioni;
    private javax.swing.JFileChooser jFileChooser1;
    private javax.swing.JFrame jFrameImpostazioni;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenuItem jMenuItemImpostazioni;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JTextField jTextFieldApriFile1;
    private javax.swing.JTextField jTextFieldApriFile2;
    private javax.swing.JTextField jTextFieldCodOrdFile1;
    private javax.swing.JTextField jTextFieldCodOrdFile2;
    private javax.swing.JTextField jTextFieldImportoFile2;
    private javax.swing.JTextField jTextFieldIntFile1;
    private javax.swing.JTextField jTextFieldIntFile2;
    private javax.swing.JTextField jTextFieldOutputFile;
    private javax.swing.JTextField jTextFieldRagSocFile1;
    private javax.swing.JTextField jTextFieldRagSocFile2;
    private javax.swing.JTextField jTextFieldValADSLfile1;
    private javax.swing.JTextField jTextFieldValVASfile1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
}
